package DBHelper;

import com.mysql.jdbc.Blob;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Param {
    private BigInteger attrId;
    private BigInteger objectId;
    private BigInteger listValueId;
    private String value;
    private Blob data;
    private Date dateValue;
    
    public Param() {}
    
    public Param(BigInteger object_id, BigInteger attr_id) throws SQLException {
        String query = "select * from params \n" +
                        "where object_id = "+object_id+" and attr_id = "+attr_id;
        ResultSet rs = DBHelper.executeQuery(query);
        while(rs.next()) {
            try {
                attrId = new BigInteger(rs.getString("attr_id"));
                objectId = new BigInteger(rs.getString("object_id"));
                listValueId = new BigInteger(rs.getString("list_value_id"));
                value = rs.getString("value");
                data = (Blob) rs.getBlob("data");
                dateValue = rs.getDate("date_value");
            }
            catch (Exception e) {e.printStackTrace();}
        }
    }
    
    public BigInteger getAttrId() {
        return attrId;
    }
    public BigInteger getObjectId() {
        return objectId;
    }
    public ListValue getListValue() throws SQLException {
        return new ListValue(listValueId);      
    }
    public BigInteger getListValueId() {
        return listValueId;
    }
    public String getValue() {
        return value;
    }
    public Blob getData() {
        return data;
    }
    public Date getDateValue() {
        return dateValue;
    }
}
